/* 
    子类虚函数私有化，则子类无法直接调用虚函数，必须通过父类来调用
*/
#include <iostream>

class A {
    public:
        virtual void hello() = 0;
};

class B : public A {
    private:
        virtual void hello() {
            std::cout << "B hello" << std::endl;
        }
}

class C : public B {
    private:
        virtual void hello() {
            std::cout << "C hello" << std::endl;
        }
}

class D : public B {
    public:
        virtual void hello() {
            std::cout << "C hello" << std::endl;
        }
}

int main()
{
    A * p0 = new B();
    A * p1 = new C();
    A * p2 = new D();

    p0->hello();
    p1->hello();
    p2->hello();

    return 0;
}